# @Time : 2020/7/17 14:20
# @Author : Fioman 
# @Phone : 13149920693
import cv2 as cv
import numpy as np

a = np.random.randint(0,255,(5,5),dtype=np.uint8)
b = np.zeros((5,5),dtype=np.uint8)

b[0:3,0:3] = 255
b[4,4] = 255

c = cv.bitwise_and(a,b)
print("a = \n",a)
print("b = \n",b)
print("c = \n",c)


img = cv.imread("lena.bmp",cv.IMREAD_GRAYSCALE)
mask = np.zeros(img.shape,dtype=np.uint8)
mask[100:400,200:400] = 255
mask[100:500,100:200] = 255

c = cv.bitwise_and(img,mask)
cv.imshow("Original",img)
cv.imshow("Mask",mask)
cv.imshow("BitwiseAnd",c)

cv.waitKey(0)
cv.destroyAllWindows()

